package com.ruoyi.secondvitim.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.secondvitim.domain.VitimInformedConsent;
import com.ruoyi.secondvitim.service.IVitimInformedConsentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 第二受害者知情同意书Controller
 * 
 * @author alonso_ecit
 * @date 2025-10-16
 */
@RestController
@RequestMapping("/secondVitim/vitimConsent")
public class VitimInformedConsentController extends BaseController
{
    @Autowired
    private IVitimInformedConsentService vitimInformedConsentService;

    /**
     * 查询第二受害者知情同意书列表
     */
    @PreAuthorize("@ss.hasPermi('secondVitim:vitimConsent:list')")
    @GetMapping("/list")
    public TableDataInfo list(VitimInformedConsent vitimInformedConsent)
    {
        startPage();
        List<VitimInformedConsent> list = vitimInformedConsentService.selectVitimInformedConsentList(vitimInformedConsent);
        return getDataTable(list);
    }

    /**
     * 导出第二受害者知情同意书列表
     */
    @PreAuthorize("@ss.hasPermi('secondVitim:vitimConsent:export')")
    @Log(title = "第二受害者知情同意书", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VitimInformedConsent vitimInformedConsent)
    {
        List<VitimInformedConsent> list = vitimInformedConsentService.selectVitimInformedConsentList(vitimInformedConsent);
        ExcelUtil<VitimInformedConsent> util = new ExcelUtil<VitimInformedConsent>(VitimInformedConsent.class);
        util.exportExcel(response, list, "第二受害者知情同意书数据");
    }

    /**
     * 获取第二受害者知情同意书详细信息
     */
    @PreAuthorize("@ss.hasPermi('secondVitim:vitimConsent:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(vitimInformedConsentService.selectVitimInformedConsentById(id));
    }

    /**
     * 新增第二受害者知情同意书
     */
    @PreAuthorize("@ss.hasPermi('secondVitim:vitimConsent:add')")
    @Log(title = "第二受害者知情同意书", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VitimInformedConsent vitimInformedConsent)
    {
        return toAjax(vitimInformedConsentService.insertVitimInformedConsent(vitimInformedConsent));
    }

    /**
     * 修改第二受害者知情同意书
     */
    @PreAuthorize("@ss.hasPermi('secondVitim:vitimConsent:edit')")
    @Log(title = "第二受害者知情同意书", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VitimInformedConsent vitimInformedConsent)
    {
        return toAjax(vitimInformedConsentService.updateVitimInformedConsent(vitimInformedConsent));
    }

    /**
     * 删除第二受害者知情同意书
     */
    @PreAuthorize("@ss.hasPermi('secondVitim:vitimConsent:remove')")
    @Log(title = "第二受害者知情同意书", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(vitimInformedConsentService.deleteVitimInformedConsentByIds(ids));
    }
}
